//
//  registerViewController.m
//  享动
//
//  Created by lanou on 16/4/6.
//  Copyright © 2016年 HHUI. All rights reserved.
//

#import "registerViewController.h"
#import "AgreementTableViewController.h"

@interface registerViewController ()<UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UIButton *backButton;

@property (weak, nonatomic) IBOutlet UITextField *textField1;
@property (weak, nonatomic) IBOutlet UITextField *textField2;
@property (weak, nonatomic) IBOutlet UITextField *textField3;
@property (weak, nonatomic) IBOutlet UITextField *textField4;
@property (weak, nonatomic) IBOutlet UIView *oneView;

@property (weak, nonatomic) IBOutlet UIView *twoView;

@property (weak, nonatomic) IBOutlet UIButton *nextButton;

@property (weak, nonatomic) IBOutlet UILabel *xieyi;
@property (weak, nonatomic) IBOutlet UIButton *xieyiButton;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *xieyiX;

@end

@implementation registerViewController

- (void)loadData
{
    NSDictionary *parDic = @{@"cellNumber":@"18014087763", @"pwd":@"shendai1727"};
    [RequestManager requestWithUrl:@"http://api.thejoyrun.com/register.aspx" requestType:RequestTypePost parDic: parDic finish:^(NSData *data) {
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
        NSLog(@"%@", dic);
    } error:^(NSError *error) {
        NSLog(@"cw");
    }];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self loadData];
    self.navigationController.navigationBar.hidden = NO;
    
    self.navigationItem.title = @"手机号注册";

    UIBarButtonItem *rightBarButton = [[UIBarButtonItem alloc]initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(rightBarButtonAction:)];
    self.navigationItem.leftBarButtonItem = rightBarButton;
    
     [self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:67 / 255.0 green:67 / 255.0 blue:67 / 255.0 alpha:0.8]];
    
    [self.backButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    
    self.oneView.backgroundColor = [UIColor colorWithRed:92/255.0 green:94/255.0 blue:102/255.0 alpha:0.5];
    
    self.twoView.backgroundColor = [UIColor colorWithRed:92/255.0 green:94/255.0 blue:102/255.0 alpha:0.5];
    
    self.textField1.placeholder = @"请输入手机号码";
    [self.textField1 setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
    self.textField1.clearButtonMode = YES;
    [self.textField1 setValue:[UIFont boldSystemFontOfSize:16] forKeyPath:@"_placeholderLabel.font"];
    
    self.textField2.placeholder = @"请输入4位验证码";
    [self.textField2 setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
    self.textField2.clearButtonMode = YES;
    [self.textField2 setValue:[UIFont boldSystemFontOfSize:16] forKeyPath:@"_placeholderLabel.font"];
    
    self.textField3.placeholder = @"请输入6-20位密码";
    [self.textField3 setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
    self.textField3.clearButtonMode = YES;
    [self.textField3 setValue:[UIFont boldSystemFontOfSize:16] forKeyPath:@"_placeholderLabel.font"];
    
    self.textField4.placeholder = @"请再次输入密码";
    [self.textField4 setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
    self.textField4.clearButtonMode = YES;
    [self.textField4 setValue:[UIFont boldSystemFontOfSize:16] forKeyPath:@"_placeholderLabel.font"];
    
    if (KWIDTH == 414) {
        self.xieyi.font = [UIFont systemFontOfSize:15];
        self.xieyiButton.titleLabel.font = [UIFont systemFontOfSize:15];
    } else if (KWIDTH == 375) {
        self.xieyi.font = [UIFont systemFontOfSize:14];
        self.xieyiButton.titleLabel.font = [UIFont systemFontOfSize:14];
    }
    
}

- (void)rightBarButtonAction:(UIButton *)button
{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [_textField1 resignFirstResponder];
    [_textField2 resignFirstResponder];
    [_textField3 resignFirstResponder];
    [_textField4 resignFirstResponder];
}
- (void)back
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (IBAction)Agreement:(id)sender {
    AgreementTableViewController *agreementVc = [[AgreementTableViewController alloc]init];
    
    [self.navigationController pushViewController:agreementVc animated:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
